<template>
  <div class="work-statistics">
    <div class="title">工作表现</div>
    <div id="workChart" class="work-chart"></div>
  </div>
</template>

<script>
import * as echarts from "echarts/core";
import {
  TooltipComponent,
  GridComponent,
  LegendComponent
} from "echarts/components";
import { LineChart } from "echarts/charts";
import { CanvasRenderer } from "echarts/renderers";

echarts.use([
  TooltipComponent,
  GridComponent,
  LegendComponent,
  LineChart,
  CanvasRenderer
]);
export default {
  props: {
    data: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  data() {
    return {};
  },
  methods: {},
  mounted: function() {
    let chart = echarts.init(document.getElementById("workChart"));

    let option = {
      legend: { textStyle: { color: "#B9BEEB" } },
      grid: { show: false },
      xAxis: {
        type: "category",
        splitLine: {
          show: true,
          lineStyle: {
            color: "#3B425B"
          }
        },
        data: this.data.xAxis.data
      },
      yAxis: [
        {
          name: "薪资浮动",
          type: "value",
          splitLine: { show: false }
          // axisLabel: {
          //   formatter: "{value} k"
          // }
        }
        // {
        //   name: "表现评分",
        //   type: "value",
        //   splitLine: { show: false },
        //   axisLabel: {
        //     formatter: "{value} 分"
        //   }
        // }
      ],
      series: [
        {
          name: "薪资浮动",
          data: this.data.series["0"].data,
          type: "line",
          lineStyle: {
            type: "dashed"
          },
          //yAxisIndex: 0,
          smooth: true
        }
        // {
        //   name: "表现评分",
        //   data: [5, 6, 4, 5, 8, 6, 4],
        //   type: "line",
        //   yAxisIndex: 1,
        //   smooth: true
        // }
      ]
    };
    chart.setOption(option);
  },
  components: {}
};
</script>
<style lang="scss">
.work-statistics {
  .title {
    color: #fff;
  }
  .work-chart {
    margin: 20px 4px;
    width: 100%;
    height: 400px;
  }
}
</style>
